/**
 * 
 */
package de.tum.in.eist.poll.client.views.widgets.evaluations;

import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.VerticalPanel;

import de.tum.in.eist.poll.shared.beans.TextAnswer;
import de.tum.in.eist.poll.shared.beans.TextQuestion;

/**
 * EvaluationWidget for a text question
 * @author Sebastian Hofstetter
 *
 */
public class QuestionTextEvaluationWidget extends QuestionEvaluationWidget{
	VerticalPanel evaluationPanel = new VerticalPanel();
	
	public QuestionTextEvaluationWidget(TextAnswer[] answers, TextQuestion question) {
		Label questionLabel = new Label(question.getQuestionText());
		questionLabel.addStyleName("question");
		evaluationPanel.add(questionLabel);
		
		// shows a notice if there are no answers yet to present
		if (answers == null || answers.length == 0) {
			evaluationPanel.add(new Label("No answers submitted yet."));
		} else {
			// shows the answer text
			for (TextAnswer a : answers) {
				evaluationPanel.add(new Label(a.getText()));
			}
		}
		
		evaluationPanel.addStyleName("QuestionTextEvaluationWidget");
				
		initWidget(evaluationPanel);
	}

}
